package com.sali.b_design_pattern.h_proxy_pattern.lesson_03_01;

import com.sali.b_design_pattern.h_proxy_pattern.lesson_01.IOrder5Service;
import com.sali.b_design_pattern.h_proxy_pattern.lesson_01.Order5ServiceImpl;
import com.sali.design_pattern.h_proxy_pattern.lesson_03_01.service.ITicketService;
import com.sali.design_pattern.h_proxy_pattern.lesson_03_01.service.impl.TicketServiceImpl;

/**
 * @description:
 * @author: zhang hang
 * @date: 2023/3/19 21:53.
 * @version: 1.0
 */
public class Test {

    public static void main(String[] args) {
        // 定义目标对象
        IOrder5Service order5Service = new Order5ServiceImpl();
        // 代理类
        com.sali.design_pattern.h_proxy_pattern.lesson_03_01.LogProxy logProxy = new com.sali.design_pattern.h_proxy_pattern.lesson_03_01.LogProxy();
        // 代理类具体的实现类
        IOrder5Service proxy = (IOrder5Service) logProxy.getProxy(order5Service);
        // 代理类执行方法（jdk动态代理在底层会进行处理和织入）
        proxy.buyTicket();

        System.out.println("=====");

        ITicketService ticketService = new TicketServiceImpl();
        com.sali.design_pattern.h_proxy_pattern.lesson_03_01.LogProxy logProxy2 = new com.sali.design_pattern.h_proxy_pattern.lesson_03_01.LogProxy();
        ITicketService proxy2 = (ITicketService) logProxy2.getProxy(ticketService);
        proxy2.getTicket(1);

    }

}
